Linux静默安装oracle19c(史上最详细的教学)

您所在的位置:网站首页 linux oracle19c卸载步骤 Linux静默安装oracle19c(史上最详细的教学)

Linux静默安装oracle19c(史上最详细的教学)

2024-06-02 11:17| 来源: 网络整理| 查看: 265

Linux静默安装oracle19c(史上最详细的教学) 1.获取主机名和ip地址 输入命令hostname和ifconfig分别获取主机名和ip地址。ip地址较为敏感,大家自行获取。 [root@wangxin ~]# hostname wangxin 2.编辑/etc/hosts 文件,在最下面加入一行(x.x.x.x代表ip地址) [root@wangxin ~]# vi /etc/hosts x.x.x.x wangxin 2.创建用户和用户组 [root@wangxin Pan]# groupadd oinstall [root@wangxin Pan]# groupadd dba [root@wangxin Pan]# groupadd oper [root@wangxin Pan]# useradd -g oinstall -G dba,oper oracle [root@wangxin Pan]# passwd oracle #修改oracle用户密码 3.创建文件夹并赋予权限 [root@wangxin Pan]# mkdir /u01/ [root@wangxin Pan]# mkdir -p /u01/app/oracle/product/19.3.0/dbhome_1 [root@wangxin Pan]# mkdir -p /u01/app/oraInventory [root@wangxin Pan]# chown -R oracle:oinstall /u01/* [root@wangxin Pan]# chmod -R 775 /u01/* 4.安装oracle所需依赖

大家可以来http://www.hebuter.cn:8071/tea 开朗网盘下载,开朗之家网站代码同步更新gitee,网站首页可以查看 也可以在此账号资源下载。

下载下来后,上传至服务器,解压到当前目录,然后在当前目录输入命令全部安装。

[root@wangxin Pan]# rpm -Uvh ./* --nodeps --force 5.拷贝oracle安装包

将官网下载的oracle安装包拷贝到/u01/app/oracle/product/19.3.0/dbhome_1目录下面。

切换oracle用户

[root@wangxin dbhome_1]# su oracle [oracle@wangxin dbhome_1]# unzip LINUX.X64_193000_db_home.zip #解压oracle安装包到当前路径 6.配置limits限制参数

编辑limits.conf,加入下面几行代码

[root@wangxin ~]# vim /etc/security/limits.conf oracle soft nproc 16384 oracle hard nproc 16384 oracle soft nofile 65536 oracle hard nofile 65536 oracle soft memlock 3145728 oracle hard memlock 3145728 7.配置PAM验证

在login文件中加入下面一行代码

[root@wangxin ~]# vim /etc/pam.d/login session required pam_limits.so 8.修改内核参数

在sysctl.conf中添加下面代码

[root@wangxin dbhome_1]# vi /etc/sysctl.conf

kernel.shmmax是共享内存,用内存 * 1024 * 1024 * 1024 * 0.9 算出结果。

kernel.shmall=kernel.shmmax / kernel.shmmni 算出来

如果你想了解下面的参数功能,请参考官方文档。

fs.file-max = 6815744 kernel.sem = 250 32000 100 128 kernel.shmall = 1073741824 kernel.shmmax = 1932735283 kernel.shmmni = 4096 kernel.panic_on_oops = 1 net.core.rmem_default = 4194304 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576 fs.aio-max-nr = 1048576 net.ipv4.ip_local_port_range = 9000 65500

使用sysctl -p 使之生效。

9.设置oracle用户环境变量

打开下面的文件,添加以下内容。

[oracle@wangxin root]$ vim /home/oracle/.bash_profile export PATH export TMP=/tmp export LANG=en_US export TMPDIR=$TMP export ORACLE_UNQNAME=orcl export ORACLE_SID=orcl export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=/u01/app/oracle/product/19.3.0/dbhome_1 export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS" PATH=$PATH:$HOME/.local/bin:$HOME/bin:$HOME/bin:$ORACLE_HOME/bin [oracle@wangxin root]$ source /home/oracle/.bash_profile #应用环境变量

需要注意的是,每次登录oracle都需要应用一次环境变量,若是想让他永久生效,则需要把上面的内容添加到 .bashrc文件中。

10.扩展虚拟内存

注意:如是内存小于4G,才需要执行此步骤,否则后面会报内存不足的问题,有些虚拟机会报,购买的云服务器若是小于4G,则必须执行此步骤,若是大于4G,则跳到下一步。

1、添加Swap分区

先切换至root用户,使用dd命令创建名为swapfile 的swap交换文件,count指定扩展4G虚拟内存。

[root@wangxin ~]# dd if=/dev/zero of=/var/swapfile bs=1024 count=4194304

2、对交换文件格式化并转换为swap分区

[root@wangxin ~]# mkswap /var/swapfile 3.挂载并且激活分区 [root@wangxin ~]# swapon /var/swapfile 4.查看新swap分区是否激活 [root@wangxin ~]# free -h total used free shared buff/cache available Mem: 1.7G 395M 76M 304K 1.3G 1.2G Swap: 4.0G 212M 3.8G 5.修改 fstab 配置,设置开机自动挂载该分区,添加如下代码 [root@wangxin ~]# vi /etc/fstab /var/swapfile swap swap defaults 0 0 6.查看是否使用了虚拟内存 [root@wangxin ~]# free 10.安装数据库软件(Oracle用户) 配置文件位置 数据库安装配置文件 /u01/app/oracle/product/19.3.0/install/response/db_install.rsp 监听配置文件 /u01/app/oracle/product/19.3.0/assistants/netca/netca.rsp 数据库创建配置文件 /u01/app/oracle/product/19.3.0/assistants/dbca/dbca.rsp 端口号配置文件 /u01/app/oracle/product/19.3.0/db_home1/network/admin/listener.ora db_install.rsp为模板文件,先备份再修改 [root@wangxin dbhome_1]$ chmod -R 755 /u01/* //此处不可以为777 [root@wangxin dbhome_1]$ chown -R oracle:oinstall /u01/* [root@wangxin dbhome_1]$ su oracle [oracle@wangxin root]$ cd /u01/app/oracle/product/19.3.0/dbhome_1/ [oracle@wangxin dbhome_1]$ cd install/response/ [oracle@wangxin response]$ cp db_install.rsp db_install.rsp.bak 编辑db_install.rsp文件 [oracle@wangxin response]$ vi db_install.rsp 修改如下参数 oracle.install.option=INSTALL_DB_SWONLY UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/u01/app/oraInventory ORACLE_HOME=/u01/app/oracle/product/19.3.0/dbhome_1 ORACLE_BASE=/u01/app/oracle **#****db版本 EE企业版 SE标准版** oracle.install.db.InstallEdition=EE oracle.install.db.OSDBA_GROUP=dba oracle.install.db.OSOPER_GROUP=dba oracle.install.db.OSBACKUPDBA_GROUP=dba oracle.install.db.OSDGDBA_GROUP=dba oracle.install.db.OSKMDBA_GROUP=dba oracle.install.db.OSRACDBA_GROUP=dba oracle.install.db.rootconfig.executeRootScript=false

执行安装程序,以oracle用户执行

[oracle@wangxin response]$ $ORACLE_HOME/runInstaller -silent -responseFile $ORACLE_HOME/install/response/db_install.rsp

如果报错

You can find the log of this install session at: /tmp/InstallActions2022-12-26_10-15-49AM/installActions2022-12-26_10-15-49AM.log [FATAL] Error in invoking target 'libasmclntsh19.ohso libasmperl19.ohso client_sharedlib' of makefile '/u01/app/oracle/product/19.3.0/dbhome_1/rdbms/lib/ins_rdbms.mk'. See '/tmp/InstallActions2022-12-26_10-15-49AM/installActions2022-12-26_10-15-49AM.log' for details. Moved the install session logs to: /u01/app/oraInventory/logs/InstallActions2022-12-26_10-15-49AM

说明oracle依赖没有安装成功。需重新安装。

重新开一个窗口登录root账号,执行下面2个脚本(root用户) 第一个脚本是对目录和用户组权限的一些修改,第二个是检查日志是否有错误。

[root@localhost ~]# /u01/app/oraInventory/orainstRoot.sh [root@localhost ~]# /u01/app/oracle/product/19.3.0/dbhome_1/root.sh

若出现如下错误,

CAUSE: Some of the mandatory prerequisites are not met. See logs for details. /u01/app/oraInventory/logs/InstallActions2021-08-20_11-08-55PM/installActions20 21-08-20_11-08-55PM.log

执行,忽略报错,再执行上面两个脚本

[oracle@wangxin logs]$ $ORACLE_HOME/runInstaller -ignorePrereq -silent -responseFile $ORACLE_HOME/install/response/db_install.rsp

在这里会有有一个问题,若是只生成了root.sh,没有orainstroot.sh脚本,说明你之前装过oracle,且卸载的时候没有删除/etc/oraInst.loc文件,此时就只会生成root.sh一个脚本, 只执行者一个即可。

11.启动默认监听

若是遇到下面的问题,你一定是忘记重新应用环境变量了。

[oracle@wangxin dbhome_1]$ lsnrctl status bash: lsnrctl: command not found...

重新应用环境变量,查看监听状态。

[oracle@wangxin dbhome_1]$ source /home/oracle/.bash_profile [oracle@wangxin dbhome_1]$ lsnrctl status LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 21-AUG-2021 07:56:07 Copyright (c) 1991, 2019, Oracle. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) TNS-12541: TNS:no listener TNS-12560: TNS:protocol adapter error TNS-00511: No listener Linux Error: 111: Connection refused

我们现在打开监听

[oracle@wangxin dbhome_1]$ lsnrctl start LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 21-AUG-2021 07:59:08 Copyright (c) 1991, 2019, Oracle. All rights reserved. Starting /u01/app/oracle/product/19.3.0/dbhome_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 19.0.0.0.0 - Production Log messages written to /u01/app/oracle/diag/tnslsnr/wangxin/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=wangxin)(PORT=1521))) Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production Start Date 21-AUG-2021 07:59:08 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Log File /u01/app/oracle/diag/tnslsnr/wangxin/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=wangxin)(PORT=1521))) The listener supports no services The command completed successfully

监听已经打开了,端口1521

12.创建新的监听

安装监听的时候一定要把默认监听停掉,否则会报错

[oracle@wangxin root]$ netca /silent /responseFile $ORACLE_HOME/assistants/netca/netca.rsp Parsing command line arguments: Parameter "silent" = true Parameter "responsefile" = /u01/app/oracle/product/19.3.0/dbhome_1/assistants/netca/netca.rsp Done parsing command line arguments. Oracle Net Services Configuration: Profile configuration complete. Oracle Net Listener Startup: The information provided for this listener is currently in use by other software on this computer. Check the trace file for details: /u01/app/oracle/cfgtoollogs/netca/trace_OraDB19Home1-2108218AM3113.log Oracle Net Services configuration failed. The exit code is 1

我们停掉监听重新建立监听。

[oracle@wangxin root]$ lsnrctl stop LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 21-AUG-2021 08:31:48 Copyright (c) 1991, 2019, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1539))) The command completed successfully [oracle@wangxin root]$ netca /silent /responseFile $ORACLE_HOME/assistants/netca/netca.rsp Parsing command line arguments: Parameter "silent" = true Parameter "responsefile" = /u01/app/oracle/product/19.3.0/dbhome_1/assistants/netca/netca.rsp Done parsing command line arguments. Oracle Net Services Configuration: Profile configuration complete. Listener "LISTENER" already exists. Oracle Net Services configuration successful. The exit code is 0

这个时候我们启动监听,可以发现默认监听是1521端口,新建的监听是1539端口。

[oracle@wangxin root]$ lsnrctl start LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 21-AUG-2021 08:34:42 Copyright (c) 1991, 2019, Oracle. All rights reserved. Starting /u01/app/oracle/product/19.3.0/dbhome_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 19.0.0.0.0 - Production System parameter file is /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora Log messages written to /u01/app/oracle/diag/tnslsnr/wangxin/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=wangxin)(PORT=1539))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521_1))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1539))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production Start Date 21-AUG-2021 08:34:42 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/wangxin/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=wangxin)(PORT=1539))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521_1))) The listener supports no services The command completed successfully 13.创建数据库

静默安装数据库先修改创建响应文件

我们先给响应文件做一个备份。响应文件在$ORACLE_HOME/assistants/dbca下面

[oracle@wangxin dbhome_1]$ cd assistants/dbca/ [oracle@wangxin dbca]$ ls dbca.rsp doc jlib templates [oracle@wangxin dbca]$ cp dbca.rsp dbca.rsp.bak

然后我们对响应文件做一个修改

gdbName=orcl sid=orcl databaseConfigType=SI templateName=General_Purpose.dbc sysPassword=JAVANUMBERONE systemPassword=JAVANUMBERONE datafileDestination={ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/ characterSet=AL32UTF8 nationalCharacterSet=UTF8 listeners=LISTENER initParams=processes=800,sga_target=1536MB,pga_aggregate_target=512MB

上面的gdbname是全局数据库名称,sid是数据库实例名,可以自己设定,syspassword和systempassword是数据库管理员密码,可以自己随意设定。然后指定了字符集,监听名字。最后面是指定了内存参数,原则上是sga_target占75%,pga_aggregate_target占25%。我电脑只有2G内存,就设定了这样,内存大的可以自行设定换取更好的性能。

开始安装数据库,安装数据库持续时间很长。

[oracle@wangxin dbca]$ dbca -silent -createDatabase -responseFile /u01/app/oracle/product/19.3.0/dbhome_1/assistants/dbca/dbca.rsp

若是出现报错

[FATAL] [DBT-50000] Unable to check for available memory. [FATAL] [DBT-50001] Unable to check the value of kernel parameter {0}

则执行安装脚本添加一个参数,去掉内存检查。

[oracle@wangxin root]$ dbca -silent -createDatabase -J-Doracle.assistants.dbca.validate.ConfigurationParams=false -responseFile /u01/app/oracle/product/19.3.0/dbhome_1/assistants/dbca/dbca.rsp

此处我遇到了一个问题,

[WARNING] ORA-03113: end-of-file on communication channel [FATAL] ORA-03114: not connected to ORACLE 然后我启动的时候报错 SQL> startup ORA-01078: failure in processing system parameters LRM-00109: could not open parameter file '/u01/app/oracle/product/19.3.0/dbhome_1/dbs/initorcl.ora' 这个问题很奇怪,我重新做过系统,用的是华为云,这一次的 network/admin/listener.ora下的配置文件居然有我重做系统前的端口号,百思不得解,系统都重做了,怎么端口号保留下来了呢。改回默认端口1521后重新安装,这次成功

修改network/admin/listener.ora文件时,若是报错权限不够,需要赋予755权限。

[root@wangxin root]$ chmod -R 755 u01/app/oracle/product/19.3.0/dbhome_1/*

到此数据库安装就已经完成了,我们可以使用命令测试一下。

[oracle@wangxin root]$ sqlplus / as sysdba

然后使用startup命令启动数据库

也可以使用pl/sql工具连接数据库测试。如果是用购买的云服务器,且用第三方工具连接,请在服务器控制台安全策略配置开放端口。

14.创建数据库报错

开始安装数据库

[oracle@wangxin dbca]$ dbca -silent -createDatabase -responseFile /u01/app/oracle/product/19.3.0/dbhome_1/assistants/dbca/dbca.rsp

如果报错说当前数据库实例名已经存在,说明你之前卸载的时候没删除/etc/oratab文件。删除它重新安装。

我这个时候报了一个错误,说是我没有监听,这个问题我还没有想明白,我指定了默认监听名为LISTENER的监听,但是报错说没有这个监听,查看监听信息我们发现监听的别名就是LISTENER。这个问题我们可以通过新建监听来解决,但是为什么报这个错还没有想明白,欢迎大佬指正。

[FATAL] [DBT-07505] Selected listener (LISTENER) does not exist. ACTION: Specify an existing listener. [oracle@wangxin etc]$ lsnrctl status LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 21-AUG-2021 08:23:48 Copyright (c) 1991, 2019, Oracle. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production Start Date 21-AUG-2021 07:59:08 Uptime 0 days 0 hr. 24 min. 40 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Log File /u01/app/oracle/diag/tnslsnr/wangxin/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=wangxin)(PORT=1521))) The listener supports no services The command completed successfully


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3